package com.genesis.yunnanji.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.genesis.yunnanji.R;
import com.genesis.yunnanji.bean.NewsBean;
import com.genesis.yunnanji.config.GenesisApiConfig;
import com.genesis.yunnanji.utils.DateUtils;

import org.xutils.image.ImageOptions;
import org.xutils.x;

import java.util.List;


public class VisitAdapter extends BaseQuickAdapter<NewsBean, BaseViewHolder> {
    private Context context;


    public VisitAdapter(Context context, @Nullable List<NewsBean> data) {
        super(R.layout.layout_visit_item, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, NewsBean item) {
        helper.setText(R.id.tv_visit_title, item.getTitle());
        helper.setText(R.id.tv_visit_readcount, "阅读  " + item.getView());
        helper.setText(R.id.tv_visit_date, DateUtils.getTimeOfMMDD(item.getAdd_time()));
        ImageOptions imageOptions = new ImageOptions.Builder().setImageScaleType(ImageView.ScaleType.FIT_XY).setCircular(true).setRadius((int) (context.getResources().getDimension(R.dimen.x60))).build();
        x.image().bind((ImageView) helper.getView(R.id.civ_visit_icon), GenesisApiConfig.PIC_HOST + item.getCover_img(), imageOptions);

    }
}
